﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Practices.Prism.Mvvm;
using Microsoft.Practices.Prism.PubSubEvents;

namespace AesonXamlControls.Interaction.AesonBusyIndicator
{
    public class AesonBusyIndicatorViewModel : BindableBase
    {

        private string message;
        public string Message
        {
            get
            {
                if (string.IsNullOrEmpty(message))
                {
                    message = "Loading...";
                }
                return message;
            }
            set { SetProperty(ref this.message, value); }
        }

        public IEventAggregator EventAggregator { get; set; }
        public AesonBusyIndicatorViewModel(IEventAggregator eag)
        {
            EventAggregator = eag;
            eag.GetEvent<BusyEvent>().Subscribe(NewMessage);
        }

        private void NewMessage(BusyEvent obj)
        {
            this.Message = obj.Message;
        }
    }


}
